package com.wnxy.controller;


import com.wnxy.dto.Result;
import com.wnxy.model.Role;
import com.wnxy.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author alice
 * @since 2021-11-12
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @GetMapping("/find")
public Result getRole(){
        List<Role> list = roleService.list();
        return Result.getInstance().setFlag(true)
                .setStatusCode(200)
                .setMessage("查询成功").setData(list);
}
    @PostMapping("/add/{roleName}")
    public Result addRole(@PathVariable("roleName") String roleName){
        roleService.addRole(roleName);
        return Result.getInstance().setFlag(true)
                .setStatusCode(200)
                .setMessage("保存成功").setData(null);
    }
}

